package com.itheima.info.manager.system.service;

import com.itheima.info.manager.system.dao.TeacherDao;
import com.itheima.info.manager.system.domain.Teacher;

public class TeacherService {
    private TeacherDao teacherDao=new TeacherDao();
    //添加老师
    public boolean addTeacher (Teacher teacher){
        return teacherDao.addTeacher(teacher);
    }

    //删除老师
    public void deleteTeacher (String sid){
        teacherDao.deleteTeacher(sid);
    }
    //修改老师
    public void updateTeacher(String sid,Teacher teacher){
teacherDao.updateTeacher(sid,teacher);
    }

    //判断工号
    public boolean isExists(String sid){
        Teacher[] teachers = teacherDao.findAllTeachers();
        for (int i = 0; i < teachers.length; i++) {
            Teacher teacher = teachers[i];
            if (teacher!=null&&teacher.getSid().equals(sid)){
                return true;
            }
        }
        return false;
    }
//查看老师
    public Teacher[] findAllTeachers() {
        Teacher[] teachers = teacherDao.findAllTeachers();
        for (int i = 0; i < teachers.length; i++) {
            Teacher teacher = teachers[i];
            if (teacher!=null){
                return teachers;
            }
        }
        return null;
    }

}
